package org.nacos.consumer.config;

import org.apache.rocketmq.common.message.MessageConst;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.function.StreamBridge;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

import lombok.extern.slf4j.Slf4j;

@Component
@Slf4j
public class ProducerConfig {

	@Autowired
    private StreamBridge streamBridge;

    public void sendMessage(Object msg) {
        // 构建消息对象
    	Message<Object> message = MessageBuilder.withPayload(msg).setHeader(MessageConst.PROPERTY_DELAY_TIME_LEVEL, 2).build();
        streamBridge.send("order-out-0", message);
        log.info("send success !");
    }
}
